import java.util.ArrayList;

/**
 * @author mazouri
 * @create 2023-03-03 10:23
 */
public class _06_reversePrint {
    public int[] reversePrint(ListNode head) {
        ArrayList<Integer> list = new ArrayList<>();
        ListNode p = head.next;
        while (p != null) {
            list.add(p.val);
            p = p.next;
        }
        int[] res = new int[list.size()];
        int j = 0;
        for (int i = list.size() - 1; i >= 0; i--) {
            res[j++] = list.get(i);
        }
        return res;
    }
}
